<?php
class QAsHistory extends CWidget {
	public $qAs;
	public $myQAs;
	
	public function init() {
		$ids = QAs::getIdsFromHistory();
		if( ! count($ids) > 0) {
			return false;
		}
		$this->qAs = QAs::model()->findAllByPk($ids);
		if($userId = Users::isLogin()) {
			$criteria = new CDbCriteria;
			$criteria->condition = 'qaAuthor = '.$userId.' AND qaParent = 0';
			$this->myQAs = QAs::model()->findAll($criteria);
		}
	}
	
	public function run() {
		if( ! count($this->qAs) > 0) {
			return false;
		}
		$this->renderContent();
	}
	
	public function renderContent() {
		$this->render('qas-history', array(
				'qAs' => $this->qAs
			)
		);
	}
}